home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / probots.arc / SLANT6.PR < prev    next >
Text File  |  1991-04-28  |  2KB  |  67 lines

  1.   PROCEDURE SLANT6;
  2.  
  3. {
  4.                             Based on C-Robot SLANT6
  5.  
  6.                                   by T. Harnish
  7.  
  8.                    This guy is a logical extension of RUNNER.
  9.                    By running on the diagonal less of the field
  10.                    is out of range.
  11.  
  12. }
  13.  
  14.     PROCEDURE GOTO(dest_x, dest_y : Integer);
  15.     BEGIN
  16.       WHILE (distance(loc_x, loc_y, dest_x, dest_y) > 100) DO
  17.         IF (speed = 0) THEN drive(Angle_To(dest_x, dest_y), 100);
  18.  
  19.       drive(0, 0); {i.e., stop}
  20.       WHILE (speed > 0) DO {nothing-- i.e., slow down} ;
  21.     END; { End GoTO }
  22.  
  23.  
  24.   BEGIN { Main routine }
  25.  
  26.  
  27.     GOTO(5, 995); { Go to upper left corner }
  28.  
  29.     REPEAT { Main loop }
  30.  
  31.       WHILE (loc_y > 150) DO { Check for bottom }
  32.         BEGIN
  33.           drive(315, 100); { Go diagonally down and right }
  34.           IF (scan(0, 10) > 0) THEN { Look right }
  35.             cannon(0, scan(0, 10)); { Shoot if you see anything }
  36.           IF (scan(90, 10) > 0) THEN { Look up }
  37.             cannon(90, scan(90, 10)); { Shoot if you see anything }
  38.           IF (scan(270, 10) > 0) THEN { Look down }
  39.             cannon(270, scan(270, 10)); { Shoot if you see anything }
  40.           IF (scan(180, 10) > 0) THEN { Look left }
  41.             cannon(180, scan(180, 10)); { Shoot if you see anything }
  42.         END; 
  43.  
  44.       drive(315, 0); { Near bottom, slow down }
  45.       WHILE (speed > 50) DO ; { Wait for slow to 50 }
  46.  
  47.       WHILE (loc_y < 850) DO { Check for top }
  48.         BEGIN
  49.           drive(135, 100); { Go diagonally up and left }
  50.           IF (scan(0, 10) > 0) THEN { Look right }
  51.             cannon(0, scan(0, 10)); { Shoot, as before }
  52.           IF (scan(270, 10) > 0) THEN { Look down }
  53.             cannon(270, scan(270, 10)); { Shoot, as before }
  54.           IF (scan(90, 10) > 0) THEN { Look up }
  55.             cannon(90, scan(90, 10)); { Shoot if you see anything }
  56.           IF (scan(180, 10) > 0) THEN { Look left }
  57.             cannon(180, scan(180, 10)); { Shoot if you see anything }
  58.         END; 
  59.  
  60.       drive(135, 0); { Slow down }
  61.       WHILE (speed > 50) DO ; { Wait for 50 }
  62.  
  63.     UNTIL Dead OR Winner;
  64.  
  65.   END; { End SLANT6 Main }
  66.  
  67.